<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns:th="http://www.thymeleaf.org">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport">
<meta content="yes" name="apple-mobile-web-app-capable">
<meta content="black" name="apple-mobile-web-app-status-bar-style">
<meta content="telephone=no" name="format-detection">
<link rel="stylesheet" href="../static/bootstrap/css/bootstrap.min.css" />
<link rel="stylesheet" type="text/css" href="../static/easyui/themes/bootstrap/easyui.css">
<link rel="stylesheet" type="text/css" href="../static/easyui/themes/icon.css">
<link rel="stylesheet" href="../static/metisMenu/metisMenu_custom.css" />
<link rel="stylesheet" href="../static/css/style-app.css" />
<script src="../static/jquery/jquery-1.12.4.js"></script>
<script src="../static/easyui/jquery.easyui.min.js"></script>
<script src="../static/easyui/locale/easyui-lang-zh_CN.js"></script>
<script src="../static/jqueryValidate/jquery.validate.min.js"></script>
<script src="../static/jqueryValidate/additional-methods.min.js"></script>
<script src="../static/jqueryValidate/localization/messages_zh.min.js"></script>
<script src="../static/moment/moment.js"></script>
<script src="../static/moment/locale/zh-cn.js"></script>
<title>日计划审核</title>
</head>

<body>
	<div class="top-part">
		<div class="header">
			<div class="return">
				<a href="javascript:history.go(-1);"></a>
			</div>
			<div class="header-title">日计划审核管理</div>
		</div>
	</div>
	<div class="new-form">
		<div>
			<form id="ff" method="post">
				<table cellpadding="5" style="margin: auto;">
					<tr>
						<td style="width: 100px;">项目：</td>
						<td>
							<input class="easyui-textbox" data-options="readonly:true" id="projectitem" name="projectitem"
								style="width: 100%;" />
						</td>
					</tr>
					<tr>
						<td style="width: 100px;">日期：</td>
						<td>
							<input class="easyui-datebox" data-options="readonly:true" id="plandate" name="plandate"
								style="width: 100%;" />
						</td>
					</tr>
					<tr>
						<td style="width: 100px;">内容：</td>
						<td colspan="3">
							<input class="easyui-textbox" data-options="readonly:true,multiline:true" id="content" name="content"
								style="width: 100%; height: 100px;" />
						</td>
					</tr>
					<tr>
						<td style="width: 100px;">形象进度：</td>
						<td colspan="3">
							<input class="easyui-textbox" data-options="readonly:true" id="percent" name="percent"
								style="width: 100%;" />
						</td>
					</tr>
					<tr>
						<td style="width: 100px;">拒绝理由：</td>
						<td>
							<input class="easyui-textbox" id="reason" name="reason" style="width: 100%; height: 80px;"
								data-options="multiline:true" />
						</td>
					</tr>
				</table>
			</form>
			<div style="text-align: center;" class="search-input">
				<a href="#" class="d-btn btn-blue" onclick="savePro()">同意</a>
				<a href="#" class="d-btn btn-red" onclick="disablecommit()">拒绝</a>
			</div>
		</div>
	</div>
</body>
<script th:inline="javascript">
	var currentPro = [[${planDaily}]];
	
	$(document).ready(function() {
		$("#projectitem").textbox("setValue",currentPro.planMain.item.name);
		$("#content").textbox("setValue",currentPro.content);
		$("#percent").textbox("setValue",currentPro.percent);
		$("#plandate").datebox("setValue",formatDate(currentPro.plandate));
	});
	
	function savePro() {
		$.ajax({
			type : 'POST',
			url : "../reviewplandaily.do?flg=true&id="+currentPro.id,
			contentType : "application/json",
			success : function(data) {
				if (data.success) {
					$.messager.alert('审核日计划', '审核日计划成功', 'success');
				} else {
					$.messager.alert('审核日计划', '审核日计划失败', 'error');
				}
				window.setInterval("window.location.href=document.referrer", 2000);
			},
			dataType : "json"
		});
	}
	
	function disablecommit() {
		var reason = $("#reason").textbox("getValue");
		$.ajax({
			type : 'POST',
			url : "../reviewplandaily.do?flg=false&id="+currentPro.id+"&reason="+reason,
			contentType : "application/json",
			success : function(data) {
				if (data.success) {
					$.messager.alert('拒绝日计划', '拒绝日计划成功', 'success');
				} else {
					$.messager.alert('拒绝日计划', '拒绝日计划失败', 'error');
				}
				window.setInterval("window.location.href=document.referrer", 2000);
			},
			dataType : "json"
		});
	}
	function formatDate(time) {
		var date = new Date(time);
		var year = date.getFullYear(), month = date.getMonth() + 1, //月份是从0开始的
		day = date.getDate(), hour = date.getHours(), min = date.getMinutes(), sec = date
				.getSeconds();
		var newTime = year + '-' + month + '-' + day;
		return newTime;
	}
</script>
</html>